package com.it.config;

import com.it.properties.AliOssProperties;
import com.it.utils.FileAliYunOssUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

@Slf4j
@SpringBootConfiguration
public class AliYunOssConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public FileAliYunOssUtils getAliOssUtil(AliOssProperties aliOssProperties) {
        log.info("创建OssUtil");
        FileAliYunOssUtils aliOssUtil = new FileAliYunOssUtils(
                aliOssProperties.getEndpoint(),
                aliOssProperties.getAccessKeyId(),
                aliOssProperties.getAccessKeySecret(),
                aliOssProperties.getBucketName()
        );
        return aliOssUtil;
    }
}
